import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { DeviceStockBo, DeviceStockVo } from './types'

// 查询库存列表
export function listStock(query: DeviceStockBo): AxiosPromise<any> {
    return request({
        url: '/vending/stock/list',
        method: 'get',
        params: query
    })
}

// 查询库存详细
export function getStock(id: number): AxiosPromise<any> {
    return request({
        url: '/vending/stock/' + id,
        method: 'get'
    })
}

// 新增库存
export function addStock(data: DeviceStockBo): AxiosPromise<any> {
    return request({
        url: '/vending/stock',
        method: 'post',
        data: data
    })
}

// 修改库存
export function updateStock(data: DeviceStockBo): AxiosPromise<any> {
    return request({
        url: '/vending/stock',
        method: 'put',
        data: data
    })
}

// 删除库存
export function delStock(id: number | number[]): AxiosPromise<any> {
    return request({
        url: '/vending/stock/' + id,
        method: 'delete'
    })
}

// 导出库存
export function exportStock(query: DeviceStockBo): AxiosPromise<void> {
    return request({
        url: '/vending/stock/export',
        method: 'get',
        params: query
    })
}

// 获取库存预警列表
export function getAlertList(query: DeviceStockBo): AxiosPromise<any> {
    return request({
        url: '/vending/stock/alert',
        method: 'get',
        params: query
    })
}

// 批量更新库存
export function batchUpdateStock(data: DeviceStockBo[]): AxiosPromise<any> {
    return request({
        url: '/vending/stock/batch',
        method: 'put',
        data: data
    })
} 